package com.plant.es.test.client_version.handler.action;

import com.plant.es.test.client_version.handler.EsInterface;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * 3.批量
 * 文档相关操作

 */
public class DocRelatedMuti implements EsInterface {
    @Override
    public void process(RestHighLevelClient esClient) {
        //创建 user 索引的文档
//        BulkRequest request = new BulkRequest();
//        request.add(new IndexRequest().index("user").id("1001").source(XContentType.JSON, "name","王五","sex","男","age",23));
//        request.add(new IndexRequest().index("user").id("1002").source(XContentType.JSON, "name","赵柳","sex","女","age",23));
//        request.add(new IndexRequest().index("user").id("1003").source(XContentType.JSON, "name","李四","sex","男","age",22));
//
//        BulkResponse responses = esClient.bulk(request, RequestOptions.DEFAULT);
//        System.out.println(responses);


        //删除 user 索引的文档
//        BulkRequest request = new BulkRequest();
//        request.add(new DeleteRequest().index("user").id("1001"));
//        request.add(new DeleteRequest().index("user").id("1002"));
//        request.add(new DeleteRequest().index("user").id("1003"));
//        BulkResponse responses = esClient.bulk(request, RequestOptions.DEFAULT);
//        System.out.println(responses);

    }
}
